package cn.zh.stan.adapter;

import android.content.Context;
import android.support.v4.content.ContextCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import org.w3c.dom.Text;

import java.util.ArrayList;

import cn.zh.stan.ITem.SItem;
import cn.zh.stan.R;

/**
 * Created by WYN on 2018/2/5 0005.
 */

public class SFAdapter extends BaseAdapter{
    Context context;
    ArrayList<SItem> arrayList;
    LayoutInflater inflater;
    public SFAdapter(Context context,ArrayList<SItem> arrayList){
        this.context=context;
        this.arrayList=arrayList;
        inflater=LayoutInflater.from(context);
      }

    @Override
    public int getCount() {
        return arrayList.size();
    }

    @Override
    public Object getItem(int i) {
        return arrayList.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        Holder holder=null;
        if (null==view){
            holder=new Holder();
            view=inflater.inflate(R.layout.sflayout,null,false);
            holder.tv=view.findViewById(R.id.sftv);
            holder.img=view.findViewById(R.id.sfimg);
            view.setTag(holder);
          }else {
            holder= (Holder) view.getTag();
          }
        holder.tv.setText(arrayList.get(i).getName());
        if (arrayList.get(i).getType().equals("0")){
            holder.img.setBackgroundResource(R.mipmap.round);
        }else {
            holder.img.setBackgroundResource(R.mipmap.round_check_fill);
        }
        return view;
    }


    class Holder{
        TextView tv;
        ImageView img;
      }



}
